package com.example.hospital.config;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.util.Date;

@Configuration
public class MyBatisPlusConfig implements MetaObjectHandler {
  @Override
  public void insertFill(MetaObject metaObject) {
    this.strictInsertFill(metaObject, "createTime", String.class, DateUtil.now());
    this.strictInsertFill(metaObject, "updateTime", String.class, DateUtil.now());
    this.strictInsertFill(metaObject, "loginDateTime", String.class, DateUtil.now());
    this.strictInsertFill(metaObject, "del", Integer.class, 0);
    //    this.strictInsertFill(metaObject, "status", Integer.class, 1);
  }
  
  
  @Override
  public void updateFill(MetaObject metaObject) {
    this.strictUpdateFill(metaObject, "updateTime", String.class, DateUtil.now());
  }
}
